package com.shop.cereshop.commons.domain.buyer;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

/**
 * 用户访客记录实体类
 */
@Data
public class CereBuyerVisitor implements Serializable {
    @TableId(type = IdType.AUTO)
    private Long buyerVisitorId;
    /**
     * 访客用户ID
     */
    private Long visitorUserId;
    /**
     * 创建时间
     */
    private LocalDateTime createTime;
    /**
     * 被访问者用户ID
     */
    private Long visitedId;
    /**
     * 更新时间
     */
    private LocalDateTime updateTime;
    /**
     * 状态：1-新访客，0-老访客
     */
    private Integer statue;
    /**
     * 访问时间
     */
    private String headImage;

    /**
     * 访问者名称
     */
    @TableField(exist = false)
    private String name;

    @TableField(exist = false)
    private Long visitTime;
    /**
     * 更新时间
     */
    @TableField(exist = false)
    private Long TimeupdateTime;
    /**
     * 访问者和被访问者之间的关系
     */
    @TableField(exist = false)
    private String relationShip;

    public void setCreateTime(LocalDateTime createTime) {
        // 将 LocalDateTime 转换为时间戳
        this.visitTime = createTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        // 将 LocalDateTime 转换为时间戳
        this.TimeupdateTime = updateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
    }

    public void setTimeupdateTime(LocalDateTime time) {
        this.updateTime = time;
    }

    public void setVisitTime(LocalDateTime time) {
        this.createTime = time;
    }
}
